import { type IMockApi } from './main'
import { range, reduce } from 'lodash-es'
import { mock } from 'mockjs'

const data: IMockApi[] = [
  {
    url: '/api/getlist',
    method: 'get',
    data: {
      code: 200,
      data: {
        'total|1-1000': 1,
        'list|15': [
          {
            id: '@id',
            name: '@cname',
            content: '@csentence(5)',
            ip: '@ip',
            'status|0-1': 1,
            phone: '@phone',
            time: "@datetime('yyyy-MM-dd HH:mm:ss')",
          },
        ],
      },
    },
  },
  {
    url: '/api/getlonglist',
    method: 'get',
    data: {
      code: 200,
      data: {
        total: 1000,
        'list|1000': [
          {
            'id|+1': 1,
            name: '@cname',
            content: '@csentence(5)',
            ip: '@ip',
            'status|0-1': 1,
            phone: '@phone',
            time: "@datetime('yyyy-MM-dd HH:mm:ss')",
          },
        ],
      },
    },
  },
  {
    url: '/api/getweightlist',
    method: 'get',
    data: {
      code: 200,
      data: {
        total: 1000,
        list: range(15).map((e: any, i: number) => ({
          id: '@id',
          ...reduce(
            range(1000),
            (obj: any, i: any) => {
              const key = `col${i}`
              obj[key] = i
              return obj
            },
            {},
          ),
        })),
      },
    },
  },
  {
    url: /\/api\/get\/\d+/,
    method: 'get',
    data: {
      code: 200,
      data: {
        id: '@id',
        name: '@cname',
        content: '@csentence(5)',
        ip: '@ip',
        'status|0-1': 1,
        phone: '@phone',
        time: "@datetime('yyyy-MM-dd HH:mm:ss')",
      },
    },
  },
  {
    url: 'stat',
    method: 'get',
    data: {
      code: 200,
      data: {
        'value1|0-10000': 1,
        'value2|0-10000': 1,
        'value3|0-100': 1,
        'value4|0-10000': 1,
        'value5|0-10000': 1,
        'value6|0-10000': 1,
      },
    },
  },
  {
    url: '/menu',
    method: 'get',
    data: {
      code: 200,
      data: {
        list: '@menu(5,15)',
      },
    },
  },
  {
    url: '/auth/role',
    method: 'get',
    data: {
      code: 200,
      data: {
        'list|5-30': [
          {
            id: '@id',
            name: '@csentence(2,7)',
            'status|0-1': 1,
            remark: '@csentence(7,25)',
          },
        ],
      },
    },
  },
  {
    url: '/auth/list',
    method: 'get',
    data: {
      code: 200,
      data: {
        'list|5-30': [
          {
            menuInfo: {
              id: '@id',
              name: '@csentence(2,7)',
              remark: '@csentence(7,25)',
            },
            'toolsList|2-12': [
              {
                id: '@id',
                name: '@csentence(2,5)',
                'has|4-1': true,
              },
            ],
          },
        ],
      },
    },
  },
  {
    url: '/user/list',
    method: 'get',
    data: {
      code: 200,
      data: {
        total: 1000,
        'list|15': [
          {
            id: '@id',
            name: '@cname',
            remark: '@csentence(7,25)',
            'role|1': range(10).map((e, i) => `${i}级用户`),
            'status|1': [1, 1, 1, 1, 1, 1, 1, 1, 0],
            account: '@word(7,9)',
          },
        ],
      },
    },
  },
]
export default data
